0 CpxTRS
↳1 TrsToWeightedTrsProof (BOTH BOUNDS(ID, ID), 0 ms)
↳2 CpxWeightedTrs
↳3 TypeInferenceProof (BOTH BOUNDS(ID, ID), 0 ms)
↳4 CpxTypedWeightedTrs
↳5 CompletionProof (UPPER BOUND(ID), 0 ms)
↳6 CpxTypedWeightedCompleteTrs
↳7 CpxTypedWeightedTrsToRntsProof (UPPER BOUND(ID), 0 ms)
↳8 CpxRNTS
↳9 CompleteCoflocoProof (⇔, 324 ms)
↳10 BOUNDS(1, n^1)
cond(true, x, y) → cond(gr(x, y), x, add(x, y))
gr(0, x) → false
gr(s(x), 0) → true
gr(s(x), s(y)) → gr(x, y)
add(0, x) → x
add(s(x), y) → s(add(x, y))
cond(true, x, y) → cond(gr(x, y), x, add(x, y)) [1]
gr(0, x) → false [1]
gr(s(x), 0) → true [1]
gr(s(x), s(y)) → gr(x, y) [1]
add(0, x) → x [1]
add(s(x), y) → s(add(x, y)) [1]
cond(true, x, y) → cond(gr(x, y), x, add(x, y)) [1]
gr(0, x) → false [1]
gr(s(x), 0) → true [1]
gr(s(x), s(y)) → gr(x, y) [1]
add(0, x) → x [1]
add(s(x), y) → s(add(x, y)) [1]
cond :: true:false → 0:s → 0:s → cond true :: true:false gr :: 0:s → 0:s → true:false add :: 0:s → 0:s → 0:s 0 :: 0:s false :: true:false s :: 0:s → 0:s |
cond(v0, v1, v2) → null_cond [0]
null_cond
Runtime Complexity Weighted TRS with Types. The TRS R consists of the following rules:
The TRS has the following type information:
Rewrite Strategy: INNERMOST |
true => 1
0 => 0
false => 0
null_cond => 0
add(z, z') -{ 1 }→ x :|: z' = x, x >= 0, z = 0
add(z, z') -{ 1 }→ 1 + add(x, y) :|: x >= 0, y >= 0, z = 1 + x, z' = y
cond(z, z', z'') -{ 1 }→ cond(gr(x, y), x, add(x, y)) :|: z' = x, z'' = y, z = 1, x >= 0, y >= 0
cond(z, z', z'') -{ 0 }→ 0 :|: v0 >= 0, z'' = v2, v1 >= 0, z = v0, z' = v1, v2 >= 0
gr(z, z') -{ 1 }→ gr(x, y) :|: z' = 1 + y, x >= 0, y >= 0, z = 1 + x
gr(z, z') -{ 1 }→ 1 :|: x >= 0, z = 1 + x, z' = 0
gr(z, z') -{ 1 }→ 0 :|: z' = x, x >= 0, z = 0
eq(start(V, V1, V2),0,[cond(V, V1, V2, Out)],[V >= 0,V1 >= 0,V2 >= 0]). eq(start(V, V1, V2),0,[gr(V, V1, Out)],[V >= 0,V1 >= 0]). eq(start(V, V1, V2),0,[add(V, V1, Out)],[V >= 0,V1 >= 0]). eq(cond(V, V1, V2, Out),1,[gr(V3, V4, Ret0),add(V3, V4, Ret2),cond(Ret0, V3, Ret2, Ret)],[Out = Ret,V1 = V3,V2 = V4,V = 1,V3 >= 0,V4 >= 0]). eq(gr(V, V1, Out),1,[],[Out = 0,V1 = V5,V5 >= 0,V = 0]). eq(gr(V, V1, Out),1,[],[Out = 1,V6 >= 0,V = 1 + V6,V1 = 0]). eq(gr(V, V1, Out),1,[gr(V7, V8, Ret1)],[Out = Ret1,V1 = 1 + V8,V7 >= 0,V8 >= 0,V = 1 + V7]). eq(add(V, V1, Out),1,[],[Out = V9,V1 = V9,V9 >= 0,V = 0]). eq(add(V, V1, Out),1,[add(V10, V11, Ret11)],[Out = 1 + Ret11,V10 >= 0,V11 >= 0,V = 1 + V10,V1 = V11]). eq(cond(V, V1, V2, Out),0,[],[Out = 0,V12 >= 0,V2 = V13,V14 >= 0,V = V12,V1 = V14,V13 >= 0]). input_output_vars(cond(V,V1,V2,Out),[V,V1,V2],[Out]). input_output_vars(gr(V,V1,Out),[V,V1],[Out]). input_output_vars(add(V,V1,Out),[V,V1],[Out]). |
CoFloCo proof output:
Preprocessing Cost Relations
=====================================
#### Computed strongly connected components
0. recursive : [add/3]
1. recursive : [gr/3]
2. recursive : [cond/4]
3. non_recursive : [start/3]
#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into add/3
1. SCC is partially evaluated into gr/3
2. SCC is partially evaluated into cond/4
3. SCC is partially evaluated into start/3
Control-Flow Refinement of Cost Relations
=====================================
### Specialization of cost equations add/3
* CE 11 is refined into CE [12]
* CE 10 is refined into CE [13]
### Cost equations --> "Loop" of add/3
* CEs [13] --> Loop 9
* CEs [12] --> Loop 10
### Ranking functions of CR add(V,V1,Out)
* RF of phase [10]: [V]
#### Partial ranking functions of CR add(V,V1,Out)
* Partial RF of phase [10]:
- RF of loop [10:1]:
V
### Specialization of cost equations gr/3
* CE 9 is refined into CE [14]
* CE 8 is refined into CE [15]
* CE 7 is refined into CE [16]
### Cost equations --> "Loop" of gr/3
* CEs [15] --> Loop 11
* CEs [16] --> Loop 12
* CEs [14] --> Loop 13
### Ranking functions of CR gr(V,V1,Out)
* RF of phase [13]: [V,V1]
#### Partial ranking functions of CR gr(V,V1,Out)
* Partial RF of phase [13]:
- RF of loop [13:1]:
V
V1
### Specialization of cost equations cond/4
* CE 6 is refined into CE [17]
* CE 5 is refined into CE [18,19,20,21]
### Cost equations --> "Loop" of cond/4
* CEs [21] --> Loop 14
* CEs [20] --> Loop 15
* CEs [19] --> Loop 16
* CEs [18] --> Loop 17
* CEs [17] --> Loop 18
### Ranking functions of CR cond(V,V1,V2,Out)
#### Partial ranking functions of CR cond(V,V1,V2,Out)
### Specialization of cost equations start/3
* CE 2 is refined into CE [22,23,24,25]
* CE 3 is refined into CE [26,27,28,29]
* CE 4 is refined into CE [30,31]
### Cost equations --> "Loop" of start/3
* CEs [27] --> Loop 19
* CEs [25] --> Loop 20
* CEs [24,28,29,31] --> Loop 21
* CEs [22,23] --> Loop 22
* CEs [26,30] --> Loop 23
### Ranking functions of CR start(V,V1,V2)
#### Partial ranking functions of CR start(V,V1,V2)
Computing Bounds
=====================================
#### Cost of chains of add(V,V1,Out):
* Chain [[10],9]: 1*it(10)+1
Such that:it(10) =< -V1+Out
with precondition: [V+V1=Out,V>=1,V1>=0]
* Chain [9]: 1
with precondition: [V=0,V1=Out,V1>=0]
#### Cost of chains of gr(V,V1,Out):
* Chain [[13],12]: 1*it(13)+1
Such that:it(13) =< V
with precondition: [Out=0,V>=1,V1>=V]
* Chain [[13],11]: 1*it(13)+1
Such that:it(13) =< V1
with precondition: [Out=1,V1>=1,V>=V1+1]
* Chain [12]: 1
with precondition: [V=0,Out=0,V1>=0]
* Chain [11]: 1
with precondition: [V1=0,Out=1,V>=1]
#### Cost of chains of cond(V,V1,V2,Out):
* Chain [18]: 0
with precondition: [Out=0,V>=0,V1>=0,V2>=0]
* Chain [17,18]: 3
with precondition: [V=1,V1=0,Out=0,V2>=0]
* Chain [16,18]: 1*s(1)+3
Such that:s(1) =< V1
with precondition: [V=1,V2=0,Out=0,V1>=1]
* Chain [16,15,18]: 3*s(1)+6
Such that:aux(2) =< V1
s(1) =< aux(2)
with precondition: [V=1,V2=0,Out=0,V1>=1]
* Chain [15,18]: 2*s(2)+3
Such that:aux(1) =< V1
s(2) =< aux(1)
with precondition: [V=1,Out=0,V1>=1,V2>=V1]
* Chain [14,18]: 1*s(4)+1*s(5)+3
Such that:s(5) =< V1
s(4) =< V2
with precondition: [V=1,Out=0,V2>=1,V1>=V2+1]
* Chain [14,15,18]: 3*s(2)+1*s(4)+6
Such that:s(4) =< V2
aux(3) =< V1
s(2) =< aux(3)
with precondition: [V=1,Out=0,V2>=1,V1>=V2+1]
#### Cost of chains of start(V,V1,V2):
* Chain [23]: 1
with precondition: [V=0,V1>=0]
* Chain [22]: 4*s(15)+6
Such that:s(14) =< V1
s(15) =< s(14)
with precondition: [V>=0,V1>=0,V2>=0]
* Chain [21]: 3*s(17)+2*s(18)+3
Such that:aux(7) =< V
aux(8) =< V1
s(18) =< aux(7)
s(17) =< aux(8)
with precondition: [V>=1,V1>=0]
* Chain [20]: 4*s(23)+2*s(24)+6
Such that:s(21) =< V1
s(22) =< V2
s(23) =< s(21)
s(24) =< s(22)
with precondition: [V=1,V2>=1,V1>=V2+1]
* Chain [19]: 1
with precondition: [V1=0,V>=1]
Closed-form bounds of start(V,V1,V2):
-------------------------------------
* Chain [23] with precondition: [V=0,V1>=0]
- Upper bound: 1
- Complexity: constant
* Chain [22] with precondition: [V>=0,V1>=0,V2>=0]
- Upper bound: 4*V1+6
- Complexity: n
* Chain [21] with precondition: [V>=1,V1>=0]
- Upper bound: 2*V+3*V1+3
- Complexity: n
* Chain [20] with precondition: [V=1,V2>=1,V1>=V2+1]
- Upper bound: 4*V1+2*V2+6
- Complexity: n
* Chain [19] with precondition: [V1=0,V>=1]
- Upper bound: 1
- Complexity: constant
### Maximum cost of start(V,V1,V2): 3*V1+2+max([2*V,V1+3+nat(V2)*2])+1
Asymptotic class: n
* Total analysis performed in 236 ms.